/*-------------------------------------
		sPlugin
	    By Scooby, 2010
-------------------------------------*/

local PLUGIN = {}

PLUGIN.Name = "Goto"
PLUGIN.Author = "Scooby"
PLUGIN.Command = "goto"
PLUGIN.Group = 2
PLUGIN.Category = "Teleport"
PLUGIN.Format = "string"
PLUGIN.Use = "<Player>"
PLUGIN.Menu = {
	{
		title = "Choose Player",
		cont = "#players",
		apos = 1
	}
}


function PLUGIN:Main( ply, args )
	
	local pl = spl:FindPly( args[1] )
	
	if( #pl == 0 ) then
		spl:PrintC( ply, spl.red, spl.fnp )
		return false
	elseif( #pl > 1 ) then
		spl:PrintC( ply, spl.red, spl.fmp )
		return false
	end
	
	local mt = ply:GetMoveType()
	
	for x=1, 100 do
		if( mt == MOVETYPE_NOCLIP ) then
			ply:SetPos( pl[1]:GetPos() + Vector( 0, 70, 0 ) )
			ply:SetMoveType( mt )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Has Gone To ", spl.green, pl[1]:Nick() )
			return true
		elseif( util.IsInWorld( pl[1]:GetPos() + Vector( 0, x + 70, 0 ) ) and util.IsInWorld( pl[1]:GetShootPos() + Vector( 0, x + 70, 0 ) ) ) then
			ply:SetPos( pl[1]:GetPos() + Vector( 0, x + 70, 0 ) )
			ply:SetMoveType( mt )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Has Gone To ", spl.green, pl[1]:Nick() )
			return true
		elseif( util.IsInWorld( pl[1]:GetPos() + Vector( x + 70, 0 , 0 ) ) and util.IsInWorld( pl[1]:GetShootPos() + Vector( x + 70, 0 , 0 ) ) ) then
			py:SetPos( pl[1]:GetPos() + Vector( x + 70, 0 , 0 ) )
			ply:SetMoveType( mt )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Has Gone To ", spl.green, pl[1]:Nick() )
			return true
		elseif( util.IsInWorld( pl[1]:GetPos() + Vector( 0, 0 , x + 100 ) )and util.IsInWorld( pl[1]:GetShootPos() + Vector( 0, 0, x + 100 ) )) then
			ply:SetPos( pl[1]:GetPos() + Vector( 0, 0 , x + 100 ) )
			ply:SetMoveType( mt )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Has Gone To ", spl.green, pl[1]:Nick() )
			return true
		end
	end
	
	spl:PrintC( spl.red, "No Where To Put You" )
	
end

spl:AddPlugin( PLUGIN )